import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { airportList } from '@apps/ant-bus/src/views/business/airport/data/api';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '订单号',
    dataIndex: 'orderNo',
    width: 160,
  },
  {
    title: '订单金额',
    dataIndex: 'totalPrice',
    width: 100,
  },
  {
    title: '订单状态',
    dataIndex: 'orderStatus',
    width: 120,
    dictData: [
      { label: '待付款', value: 1 },
      { label: '已付款', value: 2 },
      { label: '已退款', value: 3 },
      { label: '申请退款中', value: 4 },
      { label: '已关闭', value: 5 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '机场名称',
    dataIndex: 'airportName',
    width: 150,
  },
  {
    title: '管家服务名称',
    dataIndex: 'goodsName',
    width: 150,
  },
  {
    title: '联系电话',
    dataIndex: 'userPhone',
    width: 100,
  },
  {
    title: '航班号',
    dataIndex: 'flightNo',
    width: 100,
  },
  {
    title: '航班日期',
    dataIndex: 'flightDate',
    width: 100,
  },
  {
    title: '航班时间',
    dataIndex: 'flightTime',
    width: 100,
  },
  {
    title: '服务状态',
    dataIndex: 'serviceState',
    width: 120,
    dictData: [
      { label: '无需服务', value: -1 },
      { label: '待接单', value: 0 },
      { label: '已接单', value: 1 },
      { label: '已退单', value: 2 },
      { label: '服务中', value: 3 },
      { label: '已完成', value: 4 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '接单时间',
    dataIndex: 'startServiceTime',
    width: 130,
  },
  {
    title: '完成时间',
    dataIndex: 'endServiceTime',
    width: 130,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderNo',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'orderStatus',
    label: '订单状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '待付款', value: 1 },
        { label: '已付款', value: 2 },
        { label: '已退款', value: 3 },
        { label: '申请退款中', value: 4 },
        { label: '已关闭', value: 5 },
      ],
    },
  },
  {
    field: 'serviceState',
    label: '服务状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '待接单', value: 0 },
        { label: '已接单', value: 1 },
        { label: '已退单', value: 2 },
        { label: '服务中', value: 3 },
        { label: '已完成', value: 4 },
      ],
    },
  },
  {
    field: 'airportIdArray',
    label: '所属机场',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: {
      api: airportList,
      params: { handlerName: 'busAirportRoleListHandler' },
      labelField: 'airportName',
      valueField: 'airportId',
      immediate: true,
      showSearch: true,
      mode: 'multiple',
    },
  },
  {
    field: 'goodsName',
    label: '管家服务名称',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'userName',
    label: '联系人姓名',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'userPhone',
    label: '联系人电话',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'startDate',
    label: '订单开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '订单结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'flightStartDate',
    label: '起飞开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'flightEndDate',
    label: '起飞结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];
